﻿using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Entity
{
    [Table("wms_basic_product_information")]
    public class ProductInformationEntity
    {
        [Key]
        public int Product_ID { get; set; }
        
        public int? purchase_id { get; set; }
        public int? transfer_order_id { get; set; }
        public int? sales_order_id { get; set; }
        public int? warehouse_receipt_id { get; set; }
        public int? product_type_id { get; set; }
        
        [Required, MaxLength(50)]
        public string product_code { get; set; }

        [Required, MaxLength(100)]
        public string product_name { get; set; }

        [MaxLength(50)]
        public string type_of_goods { get; set; }
        [MaxLength(100)]
        public string specification_model { get; set; }

        public decimal stkInrefp { get; set; }
        public decimal outrefprc { get; set; }

        public int display_order { get; set; }
        public bool shelf_life_management { get; set; }
        public int shelf_life { get; set; }
        public int alrtdays { get; set; }

        public decimal stkmin { get; set; }
        public decimal stkmax { get; set; }
        public decimal belowmin { get; set; }
        public decimal abovemax { get; set; }
        // 新增：库存字段（用于接收查询结果）
        [NotMapped]  // 非数据库字段，仅用于传输
        public int out_warehouse_stock { get; set; }  // 调出仓库存

        [NotMapped]
        public int in_warehouse_stock { get; set; }   // 调入仓库存

        [MaxLength(20)]
        public string unit { get; set; }

        [MaxLength(200)]
        public string note { get; set; }

        [MaxLength(50)]
        public string create_by { get; set; }
        public DateTime create_time { get; set; }
        [MaxLength(50)]
        public string update_by { get; set; }
        public DateTime? update_time { get; set; }
    }
    public class ProductStockEntity
    {
        public int id { get; set; }
        public string product_code { get; set; }
        public string warehouse_name { get; set; }
        public decimal current_stock { get; set; }
        public DateTime create_time { get; set; }
        public DateTime update_time { get; set; }
    }
    public class ProductInformationEntity2
    {
        public int Product_ID { get; set; }
        public string product_code { get; set; }

        public string product_name { get; set; }

        public string specification_model { get; set; }


        public string unit { get; set; }

        public decimal stkInrefp { get; set; }

        public decimal current_inventory { get; set; }

       public string product_type_name { get; set; }
    }


    //进货订单->订单明细
    [Table("wms_basic_product_information")]
    public class ProductInformationFind
    {
        
        [Key]
        public int Product_ID { get; set; }

        public int? purchase_id { get; set; }
        public int? transfer_order_id { get; set; }
        public int? sales_order_id { get; set; }
        public int? warehouse_receipt_id { get; set; }
        public int? product_type_id { get; set; }

        [Required, MaxLength(50)]
        public string product_code { get; set; }

        [Required, MaxLength(100)]
        public string product_name { get; set; }

        [MaxLength(50)]
        public string type_of_goods { get; set; }
        [MaxLength(100)]
        public string specification_model { get; set; }

        public decimal stkInrefp { get; set; }
        public decimal outrefprc { get; set; }

        public int display_order { get; set; }
        public bool shelf_life_management { get; set; }
        public int shelf_life { get; set; }
        public int alrtdays { get; set; }

        public decimal stkmin { get; set; }
        public decimal stkmax { get; set; }
        public decimal belowmin { get; set; }
        public decimal abovemax { get; set; }

        [MaxLength(20)]
        public string unit { get; set; }

        [MaxLength(200)]
        public string note { get; set; }

        [MaxLength(50)]
        public string create_by { get; set; }
        public DateTime create_time { get; set; }
        public double current_inventory { get; set; }
        public decimal inboundPrice { get; set; } 
        public decimal currentInventory { get; set; }
    }
    
    /// <summary>
    /// 入库管理关联单号
    /// </summary>
    [Table("wms_basic_product_information")]
    public class ProductInformationFind2
    {
        [Key]
        public int Product_ID { get; set; }

        public int? purchase_id { get; set; }
        public int? transfer_order_id { get; set; }
        public int? sales_order_id { get; set; }
        public int? warehouse_receipt_id { get; set; }
        public int? product_type_id { get; set; }

        [Required, MaxLength(50)]
        public string product_code { get; set; }

        [Required, MaxLength(100)]
        public string product_name { get; set; }

        [MaxLength(50)]
        public string type_of_goods { get; set; }
        [MaxLength(100)]
        public string specification_model { get; set; }

        public decimal stkInrefp { get; set; }
        public decimal outrefprc { get; set; }

        public int display_order { get; set; }
        public bool shelf_life_management { get; set; }
        public int shelf_life { get; set; }
        public int alrtdays { get; set; }

        public decimal stkmin { get; set; }
        public decimal stkmax { get; set; }
        public decimal belowmin { get; set; }
        public decimal abovemax { get; set; }

        [MaxLength(20)]
        public string unit { get; set; }

        [MaxLength(200)]
        public string note { get; set; }

        [MaxLength(50)]
        public string create_by { get; set; }
        public DateTime create_time { get; set; }
        public double current_inventory { get; set; }
        public string StockOrderStatus {  get; set; }//单据状态
    }

    
    public class ProductWithStockDTO
    {
        public int ProductId { get; set; }
        public string ProductCode { get; set; }
        public string ProductName { get; set; }
        public string Specification { get; set; }
        public string Unit { get; set; }
        public string ProductType { get; set; }
        public decimal InPrice { get; set; }
        public int OutWarehouseStock { get; set; }
        public int InWarehouseStock { get; set; }
    }
    // 查询参数DTO
    public class ProductQueryParam
    {
        public string Keyword { get; set; } // 货品名称/编号模糊查询
        public int? ProductTypeId { get; set; } // 货品类型ID
        public string WarehouseName { get; set; } // 仓库名称模糊查询
        public int PageNum { get; set; } = 1;
        public int PageSize { get; set; } = 10;
    }

    // 表格展示数据实体
    public class ProductTableItem
    {
        public string ProductCode { get; set; }
        public string ProductName { get; set; }
        public string Status { get; set; } // 启用/停用
        public string ProductTypeName { get; set; }
        public string SpecificationModel { get; set; }
        public string WarehouseName { get; set; }
        public string LocationName { get; set; } // 关联库位表获取真实库位名称
        public int CurrentInventory { get; set; }
        public decimal InventoryAmount { get; set; } // 库存*单价
    }

 

}